package cn.edu.nju.askme.model;
// default package

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;


/**
 * Paper entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="paper"
    ,catalog="askme"
)

public class Paper  implements java.io.Serializable {


    // Fields    

     private Integer id;
     private User user;
     private String title;
     private String introduction;
     private List<PaperAnswer> paperAnswers = new ArrayList<PaperAnswer>(0);
     private List<Question> questions = new ArrayList<Question>(0);


    // Constructors

    /** default constructor */
    public Paper() {
    }

	/** minimal constructor */
    public Paper(User user, String title, String introduction) {
        this.user = user;
        this.title = title;
        this.introduction = introduction;
    }
    
    /** full constructor */
    public Paper(User user, String title, String introduction, List<PaperAnswer> paperAnswers, List<Question> questions) {
        this.user = user;
        this.title = title;
        this.introduction = introduction;
        this.paperAnswers = paperAnswers;
        this.questions = questions;
    }

   
    // Property accessors
    @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)

    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="uid", nullable=false)

    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    @Column(name="title", nullable=false, length=45)

    public String getTitle() {
        return this.title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    @Column(name="introduction", nullable=false, length=65535)

    public String getIntroduction() {
        return this.introduction;
    }
    
    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }
    @Transient
    public List<PaperAnswer> getPaperAnswers() {
        return this.paperAnswers;
    }
    
    public void setPaperAnswers(List<PaperAnswer> paperAnswers) {
        this.paperAnswers = paperAnswers;
    }
    @Transient

    public List<Question> getQuestions() {
        return this.questions;
    }
    
    public void setQuestions(List<Question> questions) {
        this.questions = questions;
    }
   








}